#include "importer.h"

#include <stdio.h>
#include <stdlib.h>

PointList * load(char * filename){
   long size;
   PointList * pl;
   Point * p = newPoint();
   int i;
   FILE * f = fopen(filename, "r");
   if(f == NULL){
      printf("No such file\n");
      return NULL; 
   }
   fscanf(f, "%ld\n", &size);

   //printf("size=%d\n", size);

   pl = newPointList(size);
  
   for(i = 0; i < size; i++){
      fscanf(f, "%lf %lf\n", &p->x, &p->y);
	  //printPoint(p);
	  addPoint(pl, p);
   }
   
   free(p);

   return pl;
}
//
///*
//int main(){
//   points * po; 
//   po = load("data.txt");
//
//   int i;
//   for(i = 0; i < po->length; i++)
//      printf("%g %g\n", po->p[i]->x, po->p[i]->y);
//
//   triangle * t = (triangle *)malloc(sizeof(triangle));
//   t = findFirstTriangle(po);
//
//   printf("dasdasdasd\n");
//   printf("a = %g\nb = %g\nc = %g\n", t->a->x, t->b->x, t->c->x);
//
//   return 0;
//}*/